﻿using AutoMapper;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Swork03_28.Domain;
using Swork03_28.Domain.Dto;

namespace Swork03_28.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class TestsController : ControllerBase
    {
        private readonly IMapper mapper;

        public TestsController(IMapper mapper)
        {
            this.mapper = mapper;
        }

        [HttpGet]
        public IActionResult Test()
        {
            var dto = new TestDto()
            {
                Id = 1,
                Age = 25,
                Name = "李四",
            };
            var test = new TestInfo()
            {
                Id = 1,
                Age = 18,
                Email = "12345",
                Name = "张三",
                Pwd = "12345",
            };
            var res = mapper.Map<TestDto, TestInfo>(dto, test);
            return Ok(res);
        }
    }
}
